import router from '@/router'

router.beforeEach((to, from, next) => {
  const whiteList = ['/login', '/register']
  if (!whiteList.includes(to.path)) {
    const token = window.localStorage.getItem('user')
    if (!token) {
      next('/login')
    } else {
      next()
    }
  }
  next()
})
